<html>
<head>
<meta charset="UTF-8">
<title>领域服务新增</title>
<link id="easyuiTheme"  href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<link href="../../static/css/esaas-easyui-edit.css" rel="stylesheet" type="text/css"/>
<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js" type="text/javascript"></script>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<body class="easyui-layout">
	<form id="ff" method="post">
		<div class="esaas-info-title">领域服务信息</div>
		<table class="esaas-info-edit-table">
			<tr>
				<td width="15%" align="right">领域服务代码：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
									   name="appModelCode" data-options="required:true"
									   style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right">领域服务名称：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
									   name="appModelName" data-options="required:true"
									   style="width: 100%; height: 25px;"></input></td>
			</tr>
			<tr>
				<td width="15%" align="right">领域服务分类：</td>
				<td width="35%"><select class="easyui-combobox"
										id="appModelCatalog" name="appModelCatalog"
										style="width: 100%; height: 25px;"
										data-options="required:true,editable:false,valueField:'enname',textField:'cnname',data:APP_MODEL_CATALOG">
				</select></td>
				<td width="15%" align="right">领域服务类型：</td>
				<td width="35%"><select class="easyui-combobox"
										id="appModelType" name="appModelType"
										style="width: 100%; height: 25px;"
										data-options="required:true,editable:false,valueField:'enname',textField:'cnname',data:APP_MODEL_TYPE"/>
				</td>
			</tr>
			<tr>
				<td width="15%" align="right">领域表模型代码：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
									   id="tableModelCode" name="tableModelCode" data-options="required:true"
									   style="width: 90%; height: 25px;">
				</input><a href="javascript:void(0)" class="easyui-linkbutton"  onclick="openSelectModelCodePage()">选择</a></td>
				<td width="15%" align="right">领域表模型名称：</td>
				<td width="35%"><input class="easyui-textbox" type="text" disabled
									   id="tableModelName" name="tableModelName" data-options="required:false"
									   style="width: 100%; height: 25px;"></input></td>
			</tr>
			<tr>
				<td width="15%" align="right">创建基础领域服务：</td>
				<td width="35%">
					<input type="checkbox" name="dataModel" value="I0102" >新增</input>
					<input type="checkbox" name="dataModel" value="I0103" >修改</input>
					<input type="checkbox" name="dataModel" value="I0104" >删除</input>
					<input type="checkbox" name="dataModel" value="I0105" >单条</input>
					<input type="checkbox" name="dataModel" value="I0101" >分页查询</input>
				</td>
			</tr>
			<tr hidden>
				<td width="15%" align="right">应用唯一标识：</td>
				<td width="35%"><input class="easyui-textbox" type="text"
									   id="appId" name="appId" data-options="required:false"
									   style="width: 100%; height: 25px;"></input></td>
				<td width="15%" align="right">表模型ID：</td>
				<td width="35%"><input class="easyui-textbox" type="text" readonly
									   id="tableModelId" name="tableModelId" data-options="required:false"
									   style="width: 100%; height: 25px;"></input></td>
			</tr>
		</table>
	</form>
	<div style="text-align: center; padding: 15px">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			onclick="submitForm()">&nbsp;保&nbsp;存&nbsp;</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			onclick="closeForm()">&nbsp;关&nbsp;闭&nbsp;</a>
	</div>
	<script>
		var appId = $.getUrlParam('appId');
		var type = $.getUrlParam("type")
		var NO_PARAMETERS = 1;
		var WITH_PARAMETERS= 2;
		$(function() {
			$('#appId').textbox('setValue',appId);
			if (type==WITH_PARAMETERS){
				$('#tableModelId').textbox('setValue',$.getUrlParam("tableModelId"));
				$('#tableModelCode').textbox('setValue',$.getUrlParam("tableModelCode"));
				$('#tableModelName').textbox('setValue',$.getUrlParam("tableModelName"));
			}
		});
		function submitForm() {
			if (!$('#ff').form('validate'))
				return;
			var jsonData = $("#ff").serializeJson();
			var dataModels = jsonData.dataModel;
			delete jsonData.dataModel;
			jsonData.appId = appId;
			$.restfulPostJson('../../api/app/model/info', jsonData, function(data) {
				if (dataModels && dataModels.length > 0) {
					var initData = {
						objectId : jsonData.tableModelId,
						tableModelCode: jsonData.tableModelCode,
						appModelType: dataModels.join(','),
					};
					$.restfulPostJson('../../api/sd/app/init/create/I01/' + appId, initData, function(data) {
						$.messager.alert('提示','数据服务初始化成功!','info');
					});
				}
				window.parent.reloadList();
				closeForm();
			});

		};
		
		function closeForm() {
			window.parent.JLEUtil.closewin();
		}
		
		function setModelTypeVal(value) {
			$("#appModelType").combobox('setValue', value);
		}
		
		function openSelectModelCodePage() {
			JLEUtil.createModalWin('选择表模型代码', `AppTableModelCodeSelectPage.html?appId=${appId}`);
		}
		
		function setModelCodeValue(data) {
			$('#tableModelCode').textbox('setValue', data.objectCode);
			$('#tableModelName').textbox('setValue', data.objectName);
			$('#tableModelId').textbox('setValue', data.objectId);
		}
	</script>
</body>
</html>
